package control
{
	import model.ModelLocator;
	import flash.events.Event;
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.RemoteObject;
	public class ShowTypeMarkers
	{
		internal var theModel:ModelLocator = ModelLocator.getInstance();
		private var ShowTypeMarkersRO:RemoteObject;
		public function ShowTypeMarkers()
		{
			ShowTypeMarkersRO = new RemoteObject();
			ShowTypeMarkersRO.destination="ShowTypeMarkers";
			ShowTypeMarkersRO.doShowTypeMarkers.addEventListener(ResultEvent.RESULT,ShowTypeMarkersResultHandler);
			ShowTypeMarkersRO.addEventListener(FaultEvent.FAULT, ShowTypeMarkersFaultHandler);
		}
		
		public function doShowTypeMarkers(markertype:String):void
		{
			ShowTypeMarkersRO.doShowTypeMarkers(markertype);
		}
		
		internal function ShowTypeMarkersResultHandler(event:ResultEvent):void
		{
			//	Alert.show("search type Marker Successfully.");
			//	if(mark.searchtype.text == "myown")
					theModel.allTheTypeMarkers = event.result as ArrayCollection;
				//Alert.show(theModel.allShowTypeMarkers[1]['username']);
				theModel.dispatchEvent(new Event(ModelLocator.SHOWTYPEMARKERS_OK));
		}
		
		internal function ShowTypeMarkersFaultHandler(event:FaultEvent):void
		{
			Alert.show("error occur when search type marker");
		}
	}
}